package com.fengye.algorithms.huawei;

import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

/**
 * https://www.nowcoder.com/practice/e896d0f82f1246a3aa7b232ce38029d4?tpId=37&tqId=21282&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3FtpId%3D37&difficulty=undefined&judgeStatus=undefined&tags=&title=
 * @Author fengye
 * @Date 2023/4/7 11:10
 **/
public class CharOneTimeMain {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNext()) {
            String str = in.next();
            char[] chs = str.toCharArray();
            List<Character> list = new LinkedList<>();
            List<Character> hasRemove = new LinkedList<>();
            for (char ch : chs) {
                if ((list.isEmpty() || !list.contains(ch)) && !hasRemove.contains(ch)) {
                    list.add(ch);
                    continue;
                }

                if (list.contains(ch)) {
                    list.remove(Character.valueOf(ch));
                    hasRemove.add(ch);
                    continue;
                }
            }
            if(list.isEmpty()) {
                System.out.println(-1);
                continue;
            }
            Character res = list.stream().findFirst().get();
            System.out.println(res);
        }
    }
}
